<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>编辑图书</title>
  <style>
    body {
      font-family: Arial, sans-serif;
    }
    .container {
      width: 50%;
      margin: 50px auto;
      padding: 20px;
      border: 1px solid #ccc;
      border-radius: 10px;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    }
    .container h2 {
      text-align: center;
    }
    .form-group {
      margin-bottom: 15px;
    }
    .form-group label {
      font-weight: bold;
    }
    .form-group input, .form-group select {
      width: 100%;
      padding: 10px;
      margin-top: 5px;
      border: 1px solid #ccc;
      border-radius: 5px;
    }
    .action-buttons {
      text-align: center;
      margin-top: 20px;
    }
    .btn {
      padding: 10px 20px;
      background-color: #4CAF50;
      color: white;
      border: none;
      border-radius: 5px;
      cursor: pointer;
    }
    .btn:hover {
      background-color: #45a049;
    }
    .btn-cancel {
      background-color: #f44336;
    }
    .btn-cancel:hover {
      background-color: #e53935;
    }
  </style>
</head>
<body>

<div class="container">
  <h2>编辑图书</h2>

  <form action="BooksEdit" method="post">
    <!-- 隐藏的 bookId 字段 -->
    <input type="hidden" name="bookId" value="${books.bookId}">

    <div class="form-group">
      <label for="bookName">图书名称</label>
      <input type="text" id="bookName" name="bookName" value="${books.bookName}" required>
    </div>

    <div class="form-group">
      <label for="category">图书类别</label>
      <select id="category" name="category" required>
        <option value="">请选择类别</option>
        <option value="文学" ${books.category == '文学' ? 'selected' : ''}>文学</option>
        <option value="科技" ${books.category == '科技' ? 'selected' : ''}>科技</option>
        <option value="历史" ${books.category == '历史' ? 'selected' : ''}>历史</option>
        <option value="艺术" ${books.category == '艺术' ? 'selected' : ''}>艺术</option>
        <option value="其他" ${books.category == '其他' ? 'selected' : ''}>其他</option>
      </select>
    </div>

    <div class="form-group">
      <label for="author">作者</label>
      <input type="text" id="author" name="author" value="${books.author}" required>
    </div>

    <div class="form-group">
      <label for="publisher">出版社</label>
      <input type="text" id="publisher" name="publisher" value="${books.publisher}" required>
    </div>

    <div class="form-group">
      <label for="language">语言</label>
      <input type="text" id="language" name="language" value="${books.language}" required>
    </div>

    <div class="form-group">
      <label for="price">价格</label>
      <input type="number" id="price" name="price" value="${books.price}" required>
    </div>

    <div class="form-group">
      <label for="publishDate">出版日期</label>
      <input type="date" id="publishDate" name="publishDate" value="${books.publish_date}" required>
    </div>

    <div class="action-buttons">
      <button type="submit" class="btn">保存</button>
      <a href="home.jsp" class="btn btn-cancel">取消</a>
    </div>
  </form>
</div>

</body>
</html>